import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '名字',
    align: "center",
    sorter: true,
    dataIndex: 'name'
  },
  {
    title: '省市',
    align: "center",
    sorter: true,
    dataIndex: 'department',
    slots: { customRender: 'pcaSlot' },
  },
  {
    title: '人员',
    align: "center",
    dataIndex: 'people_dictText'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'status',
    customRender:({text}) => {
       return  render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}]);
     },
  },
  {
    title: '班级',
    align: "center",
    dataIndex: 'classes_dictText'
  },
  {
    title: '性别',
    align: "center",
    dataIndex: 'sex_dictText'
  },
  {
    title: '生日',
    align: "center",
    dataIndex: 'birthday',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '体重',
    align: "center",
    dataIndex: 'bodyWeight'
  },
  {
    title: '电子邮件',
    align: "center",
    dataIndex: 'email'
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'notes'
  },
  {
    title: '照片',
    align: "center",
    dataIndex: 'photo',
    customRender: render.renderImage,
  },
  {
    title: '档案文件',
    align: "center",
    dataIndex: 'files',
    slots: { customRender: 'fileSlot' },
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "名字",
    field: 'name',
    component: 'Input',
    colProps: {span: 6},
  },
  {
    label: "省市",
    field: 'department',
    component: 'JAreaLinkage',
    colProps: {span: 6},
  },
  {
    label: "状态",
    field: 'status',
    component: 'JSwitch',
    componentProps:{
    },
    colProps: {span: 6},
  },
  {
    label: "班级",
    field: 'classes',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "mwx_class,classname,classname"
    },
    colProps: {span: 6},
  },
  {
    label: "生日",
    field: "birthday",
    component: 'RangePicker',
    colProps: {span: 6},
  },
  {
    label: "体重",
    field: "bodyWeight",
    component: 'JRangeNumber',
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '名字',
    field: 'name',
    component: 'Input',
  },
  {
    label: '省市',
    field: 'department',
    component: 'JAreaLinkage',
  },
  {
    label: '人员',
    field: 'people',
    component: 'JSelectUserByDept',
    componentProps:{
      labelKey: 'realname',
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JSwitch',
    componentProps:{
    },
  },
  {
    label: '班级',
    field: 'classes',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "mwx_class,classname,classname"
    },
  },
  {
    label: '性别',
    field: 'sex',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "sex"
    },
  },
  {
    label: '生日',
    field: 'birthday',
    component: 'DatePicker',
  },
  {
    label: '体重',
    field: 'bodyWeight',
    component: 'InputNumber',
  },
  {
    label: '电子邮件',
    field: 'email',
    component: 'Input',
  },
  {
    label: '备注',
    field: 'notes',
    component: 'InputTextArea',
  },
  {
    label: '照片',
    field: 'photo',
    component: 'JImageUpload',
    componentProps:{
    },
  },
  {
    label: '档案文件',
    field: 'files',
    component: 'JUpload',
    componentProps:{
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
